package com.chushouya.controller.manager.clerk;

import com.chushouya.common.annotations.AuthSkip;
import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.schema.Response;
import com.chushouya.manager.dto.admin.user.login.ClerkLoginDTO;
import com.chushouya.manager.dto.admin.user.login.SmsLoginDTO;
import com.chushouya.manager.dto.admin.user.login.UserInfoDTO;
import com.chushouya.manager.service.api.UserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * c端用户登录接口
 */
@RestController
@RequestMapping(ServiceType.CLERK + "/login")
@Api(tags = "登录接口")
public class ClerkLoginApiController {

    @Resource
    private UserLoginService userLoginService;


    @PostMapping("/clerkLogin")
    @ApiOperation("业务员登录")
    @AuthSkip
    public Response<UserInfoDTO> clerkLogin(@RequestBody @Valid ClerkLoginDTO dto) {
        return Response.success(userLoginService.clerkLogin(dto));
    }

    @PostMapping("/clerkSmsLogin")
    @ApiOperation("业务员短信登录")
    @AuthSkip
    public Response<UserInfoDTO> clerkSmsLogin(@RequestBody @Valid SmsLoginDTO dto) {
        return Response.success(userLoginService.clerkSmsLogin(dto));
    }
}
